#include <stdio.h>
#include <stdlib.h>

struct Ll{
	int val;
	struct Ll *next;
};

typedef struct Ll node;

//generate a random sized, random valued linked list
node* get_random_list(){
	srand((unsigned int)time(NULL));

	node* head;	
	node* prev;
	int i = 0;
	int limit = rand()%10;
	for(i = 0; i <= limit; i++){
		node* n = (node*)malloc(sizeof(node));
	      	n->val = rand()%100;
		if(i==0){
		  head = n;
		}else{
		  prev->next = n;
		}
		if(i == limit) n->next = NULL;
		prev = n;

	}	
	return head;
}
//calculates the length of a linked list
int length_Ll(node *head){
	int length = 0;
	node *current = head;
	while(current != NULL){
		length++;
		current = current->next;
	}
	return length;
}

//prints the contents of the linked list
void print_linkedlist(node* head){
	node* current = head;
	while(current != NULL){
		printf("%d->", current->val);
		current = current->next;
	}
	printf("NULL\n");
}
int main(){
	node* head = get_random_list();
	print_linkedlist(head);
	return 1;
}
